//-----------------------------------------------------------------------
// <copyright file="UserServiceBase.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using Pyco;
using Pyco.Diagnostics;
using Pyco.Data;
using BirthdayReminder.Entities;
using BirthdayReminder.Data;
    
namespace BirthdayReminder.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class UserServiceBase
    {
        #region UserServiceBase

        public static void CreateUser(User user)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                userDAO.CreateUser(user);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessCreateUserException, ex);
            }
        }

        public static void UpdateUser(User user)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                userDAO.UpdateUser(user);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessUpdateUserException, ex);
            }
        }        

        public static void DeleteUser(int userId)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                userDAO.DeleteUser(userId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessDeleteUserException, ex);
            }
        }
		
        public static User GetUser(int userId)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                return userDAO.GetUser(userId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetUserException, ex);
            }
        }                
		
        public static UserCollection GetUserList(UserColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                return userDAO.GetUserList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetUserListException, ex);
            }
        }        

        public static UserCollection GetUserList(UserColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                UserDAO userDAO = new UserDAO();
                return userDAO.GetUserList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetUserListException, ex);
            }
        }        
		
		
        #endregion
    }
}